package com.hyc.myvideo.widget;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.StyleRes;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.hyc.myvideo.R;

/**
 * 开通VIP
 * Created by dfeads on 2017/7/28.
 */

public class VIPDialog extends Dialog {
  /** 账户余额 */
  @BindView(R.id.dialog_vip_balance) TextView mVipBalance;
  /** 普通用户所需 */
  @BindView(R.id.dialog_vip_user_common) TextView mUserCommon;
  /** VIP用户只需 */
  @BindView(R.id.dialog_vip_user_vip) TextView mUserVip;
  @BindView(R.id.dialog_vip_confirm) TextView mConfire;

  private String mBanlance = "";
  private String mCommon = "";
  private String mVIP = "";
  private int type = 0;//0:余额足够，1：余额不足

  private VIPsDialog.OnVIPsListener onVIPsListener;

  public void setOnVIPsListener(VIPsDialog.OnVIPsListener onVIPsListener) {
    this.onVIPsListener = onVIPsListener;
  }

  public String getmBanlance() {
    return mBanlance;
  }

  public void setmBanlance(String mBanlance) {
    this.mBanlance = mBanlance;
  }

  public String getmCommon() {
    return mCommon;
  }

  public void setmCommon(String mCommon) {
    this.mCommon = mCommon;
  }

  public String getmVIP() {
    return mVIP;
  }

  public void setmVIP(String mVIP) {
    this.mVIP = mVIP;
  }

  public int getType() {
    return type;
  }

  public void setType(int type) {
    this.type = type;
  }

  public VIPDialog(@NonNull Context context) {
    this(context, R.style.myDialogStytle);
  }

  public VIPDialog(@NonNull Context context, @StyleRes int themeResId) {
    super(context, themeResId);
    init(context);
  }

  private void init(Context context) {
    View view = LayoutInflater.from(context).inflate(R.layout.dialog_vip, null);
    setContentView(view);
    ButterKnife.bind(this, view);
    mVipBalance.setText("您目前账户余额：" + mBanlance + "(颗)");
    mUserCommon.setText("普通用户所需：" + mCommon + "(颗)");
    mUserVip.setText("VIP用户只需：" + mVIP + "(颗)");
    switch (type) {
      case 0:
        mConfire.setText("确定");
        break;
      case 1:
        mConfire.setText("充值");
        break;
    }
  }

  @OnClick({ R.id.dialog_vip_cancel, R.id.dialog_vip_confirm })
  public void onViewClicked(View view) {
    switch (view.getId()) {
      case R.id.dialog_vip_cancel:
        dismiss();
        break;
      case R.id.dialog_vip_confirm:
        if (onVIPsListener != null) {
          onVIPsListener.toSure(type);
          dismiss();
        }
        break;
    }
  }
}
